home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16809 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.6 KB

  1. Path: ivan.iecc.com!not-for-mail
  2. From: John Mitchell <104316.1514@CompuServe.COM>
  3. Newsgroups: comp.compilers,comp.lang.c++
  4. Subject: SUMMARY: parsing C++ header files
  5. Date: 11 Apr 1996 23:50:57 -0400
  6. Organization: Claremont Technologies
  7. Sender: johnl@iecc.com
  8. Approved: compilers@ivan.iecc.com
  9. Message-ID: <96-04-079@comp.compilers>
  10. References: <96-04-033@comp.compilers>
  11. Reply-To: johnm@mitchell.org
  12. NNTP-Posting-Host: localhost.iecc.com
  13. Keywords: C++, parse, summary
  14.  
  15.  
  16. Hi Everyone,
  17.  
  18. A few days ago I posted a query for information about parsing C++
  19. header files.  In response to a couple of requests, heres a summary of
  20. responses.
  21.  
  22. Firstly, another request: Most of the feedback related to full-scale
  23. C++ compilation rather than header file parsing, so if you've any
  24. insights on:
  25.  
  26. - any tools available that could be applied to the problem of
  27. extracting C++ class interface information (methods, public data
  28. members, inheritance)
  29.  
  30. - the specific difficulties ( lookahead problems etc) of C++ interface
  31. extraction from header files, as opposed to full C++ parsing
  32.  
  33. - whether templates add extra ambiguities to header file parsing in
  34. addition to those discussed by Roskind (see below)
  35.  
  36. --I'd be interested to hear your comments.
  37.  
  38. The original request was:
  39.  
  40.  
  41. >I want to parse C++ header files, and extract information about the
  42. >contained classes and their interface. A yacc-able grammar for this
  43. >type of problem ( or superset of it, as for compilation) would be a
  44. >great help. I'm aware of a grammar for C++ 2.0 out there - is there a
  45. >later version supporting templates?
  46. >
  47. >Alternatively, any suggestions on shareware/commercial parsers
  48. >(Windows/UNIX) that would be up to the job would be appreciated.
  49. >
  50.  
  51. Firstly, the grammar I namedropped in the above is at lots of repositories
  52. e.g. ftp://ftp.funet.fi/pub/languages/c++/c++grammar2.0.tar.gz
  53.  
  54. Some comments:
  55.  
  56. from "John H. Spicer", INTERNET:jhs@edg.com:
  57.  
  58. >Edison Design Group (EDG) sells a C++ front end that can certainly do
  59. >the job.  It isn't cheep, but doing a parser that understands all of
  60. >C++ is no small task (particularly if you want to handle the full
  61. >language including templates, namespaces,
  62.  
  63. from Mary Fernandez, INTERNET:mff@research.att.com
  64. ----
  65. I would suggest looking at two tools:
  66. Sage++ at http://www.extreme.indiana.edu/sage/overview.html, and
  67. the EDG C++ frontend at http://www.edg.com
  68.  
  69. Sage is in the public domain, the EDG front end is not.  However, EDG
  70. may have some fair-use agreement for academics.  So you'd have to
  71. contact them to determine if it's free.  I have only passing knowledge
  72. of Sage, but have looked at EDG's internal rep quite a bit.  The
  73. benefit of EDG's frontend is that it is a commercial, full-fledged C++
  74. front end (i.e., it covers the complete ARM) and it's internal rep
  75. (IR) is very well documented (this is rare).  Sage++ also appears to
  76. be well documented and there is an API for accessing its IR.  Also,
  77. you might find the EDG IR easier to manipulate than having to hack a
  78. C++ grammar.
  79. -----
  80.  
  81. from me:
  82.  
  83. Shareware:
  84.  
  85. Roskinds C++ grammar (version 2.0, parses C++ 2.1) is the latest
  86. shareware grammar that I have been able to locate. Theres an excellent
  87. discussion in the documentation of C++ specific parsing problems.  (
  88. Most importantly, deciding whether something is an expression or
  89. statement requires lookahead, and Yacc cant do this bit, you need a
  90. "smart lexer" that can look ahead and discriminate).
  91.  
  92. (Note: Roskind mentioned lack of consensus on what constitutes the C++
  93. langauage as the reason for not providing templates, exception
  94. handling etc. Since then C++ vendors have gone off implementing these
  95. features in different ways - so the definition of what constitutes a
  96. "C++ grammar" depends on who you're talking to)
  97.  
  98. Commercial:
  99. pcyacc from Abraxas  also has a grammar based on Roskind's pre-templates
  100.  (primarily, they say because of lack of consensus on the language rather than
  101.  technical difficulties, they can offer support on adding them)
  102.  They support a more specific and current range of compilers in their
  103. codecheck product ( using codecheck rules rather than yacc )
  104.  
  105. VisualParse++ from Sandstone (503) 244 5253, have a C++ grammar based
  106. on Roskinds, and again pre-templates. They claim their parser can
  107. represent any LALR(k) language (using "InfiLook", not Yacc).
  108.  
  109. Don't have any more info on how good these products and their internal
  110. representations are ( though representatives from both impressed me as
  111. being extremely knowledgable).
  112.  
  113. So thats it - I'recommend Roskind's discussion notes as a first
  114. ( and maybe last ) step.
  115.  
  116. John Mitchell
  117.  
  118. --
  119. Send compilers articles to compilers@iecc.com,
  120. meta-mail to compilers-request@iecc.com.
  121.